@extends('hrs.layouts.app')  
@section('css')


        <link href="{{asset('hrs/plugins/ladda-buttons/css/ladda-themeless.min.css')}}" rel="stylesheet" type="text/css" /> 
        <link href="{{asset('hrs/plugins/select2/css/select2.min.css')}}" rel="stylesheet" type="text/css" />
 <link href="{{asset('hrs/plugins/bootstrap-daterangepicker/daterangepicker.css')}}" rel="stylesheet">
  
@endsection         
@section('content')

            <div class="container">
                    @if(session('rs'))
                              <div class="alert alert-{{session('rs')['status']}}">
                                {{ session('rs')['msg'] }}
                              </div>
                    @endif
              
                <div class="row">
                    <div class="col-sm-12">

                        <div class="card-box">
                        
                            <div class="row">
                <form method="get" action="{{url('itemfees')}}" id="form1">
                            
                                <div class="col-lg-12">       
                           

                                    
                                       <div class="form-group  col-md-3">
                                            <label class="col-md-4">提单号</label>
                                            <div class="col-md-8">
                                                <input type="text" class="form-control" placeholder="" name="code"  value="{{array_get($where,'code')}}">
                                            </div>
                                        </div>
                                        <div class="form-group  col-md-3">
                                            <label class="col-md-4">关系人</label>
                                            <div class="col-md-8">
                                                <input type="text" class="form-control" placeholder="" name="contacter"  value="{{array_get($where,'contacter')}}">
                                            </div>
                                        </div>

                                        <div class="form-group col-md-3">
                                            <label  class="col-md-3">船名</label>
                                            <div class="col-md-9">
                                            <input type="text" class="form-control" placeholder="" name="ship_name" value="{{array_get($where,'ship_name')}}" >
                                        </div>
                                        </div>

                                        <div class="form-group  col-md-3">
                                            <label class="col-md-3">航次</label>
                                            <div class="col-md-9">
                                            <input type="text" class="form-control" placeholder="" name="ship_line" value="{{array_get($where,'ship_line')}}" >
                                            </div>
                                        </div>
                                        <div class="form-group  col-md-4">
                                            <label class="col-md-3">费用类型</label>
                                            <div class="col-md-9">
                            <select name="money_type" class="form-control">
                                <option value="receive" {{array_get($where,'money_type')=='receive'?'selected':''}}>应收</option>
                                <option value="pay" {{array_get($where,'money_type')=='pay'?'selected':''}}>应付</option>
                                <option value="received" {{array_get($where,'money_type')=='received'?'selected':''}}>已收</option>
                                <option value="paied" {{array_get($where,'money_type')=='paied'?'selected':''}}>已付</option>
                            </select>
    
                                            </div>
                                        </div>
                                        
                                        

            <div class="form-group col-md-6">
                <label class="col-md-2">日期</label>
                <div class="col-md-10">
                    <div id="reportrange" class="pull-right form-control">
                        <i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
                        <span></span>
                    </div>
                </div>    
                <input name="start_date" type="hidden" value="{{array_get($param,'start_date')}}" />
                <input name="end_date" type="hidden" value="{{array_get($param,'end_date')}}" />
            </div>

            <div class="form-group col-md-2">
                 <button type="button" class="btn  btn-primary btn-src" >查找</button>
           
                <buttonn type="button" class="btn btn-info btn-export">导出</a>
            </div>
                                    
                                </div>
                               </form>     
                            </div>
                            
                            <hr/>
                            <div class="row">
                                   
                                
                                <div class="col-lg-12">
            
                                    <h5 class="text-muted text-uppercase m-t-0 m-b-10"><b>费用信息</b></h5>
                                        
                                        <div class="table-responsive">
                                <table class="table table-hover table table-actions-bar">
                                    <thead>
                                        <tr>

                                            <th>提单号</th>
                                            <th>费目</th>
                                            <th>应收</th>
                                           
                                            <th>应收状态</th>
                                            <!-- <th>发票</th> -->
                                            <th>应收关系人</th>
                                            <th>应付</th>                                       

                                            <th>应付状态</th>
                                            <th>应付关系人</th>
                                            <th>日期</th>
                                            <th>备注</th>
                                            
                                        </tr>
                                    </thead>

                                    <tbody>
                                        @foreach($list as $v)
                                        <tr >

                                            <td>{{object_get($v,'item.code')}}</td>

                                            <td>{{$v->fee_name}}</td>
                                            <td>
                                                {{$v->receive_money}}
                                            </td>
                                            <td><span class="label label-{{$v->receive_status_style}}"  title="{{$v->receive_at}}">
                                                {{$v->receive_status_txt}}
                                                </span> 
                                                <select name="receive_status" class="change-stauts" data-type="receive" data-id="{{$v->id}}">
                                                    <option value="">修改</option>
                                                    <option value="1">已收</option>
                                                    <option value="0">未收</option>
                                                </select>
                                            </td>
                                            <!-- <td><span class="label label-{{$v->receive_status_style}}"  title="{{$v->receive_at}}">
                                                未开
                                                </span> 
                                                
                                            </td> -->
                                           
                                            <td>{{$v->receive_contacter}}</td>
                                            <td>
                                              {{$v->pay_money}} 
                                            </td>
                                           
                                            <td>

                                                <span class="label label-{{$v->pay_status_style}}"  title="{{$v->pay_at}}">
                                                {{$v->pay_status_txt}}
                                                </span> 
                                                <select name="pay_status" class="change-stauts" data-type="pay" data-id="{{$v->id}}">
                                                    <option value="">修改</option>
                                                    <option value="1">已收</option>
                                                    <option value="0">未收</option>
                                                </select>

                                                

                                            </td>
                                            <td>{{$v->pay_contacter}}</td>
                                            <td>{{$v->item->created_at->format('Y-m-d')}}</td>
                                            
                                            <td>{{object_get($v,'item.remark')}}</td>
                                           
                                            
                                        </tr>
                                        @endforeach

                                        


                                        

                                    </tbody>
                                </table>
                            </div>
                            {{$list->appends($where)->links()}}
                            <hr/>
                            <div class="col-lg-12">
                                    <div class="col-md-3">
                                        <a class="btn btn-info">费用小计</a>
                                    </div>
                                    <div class="col-md-3">
                    应收合计：<span class="label label-success">{{$type['receive_money']}}</span>
                                    </div>
                                    <div class="col-md-3">    
                                        应付合计：<span class="label label-danger">{{$type['pay_money']}}</span>
                                    </div>
                                </div> 
                          
                             
   
                                </div>
                                    
                            </div>
                           

  
                        
                        
                    </div>
                </div>
 </div>
               

            </div> <!-- end container -->
@endsection        

        
@section('js')
  <!-- Modal-Effect -->
<script src="{{asset('hrs/plugins/ladda-buttons/js/spin.min.js')}}"></script>
<script src="{{asset('hrs/plugins/ladda-buttons/js/ladda.min.js')}}"></script>
<script src="{{asset('hrs/plugins/ladda-buttons/js/ladda.jquery.min.js')}}"></script>
<script src="{{asset('js/sweetalert.min.js')}}"></script>
   <script src="{{asset('hrs/plugins/select2/js/select2.min.js')}}" type="text/javascript"></script>
    <script src="{{asset('hrs/plugins/moment/moment.js')}}"></script>    
    <script src="{{asset('hrs/plugins/bootstrap-daterangepicker/daterangepicker.js')}}"></script>
    <script type="text/javascript">
        $('.btn-export').on('click',function(){
            var url ="{{url('itemfees/export')}}";
            $('#form1').attr('action',url).submit();
        });

        $('.btn-src').on('click',function(){
            var url = "{{url('itemfees')}}";
            $('#form1').attr('action',url).submit();
        })

        $('.change-stauts').on('change',function(){
            var _this = $(this);
            var data = {};
             data.id = _this.data('id');
             data.type = _this.data('type');
             data.status = _this.val();
             var url = "{{url('itemfees/change-status')}}";
             $.get(url,data,function(rs){
                if(rs.status) {
                    window.location.reload();
                } else {
                    alert('操作失败');
                }
             });

        });

        
        @if(array_get($param,'start_date'))
        $('#reportrange span').html('{{$param['start_date']}}' + ' 至 ' + '{{$param['end_date']}}');
        $('input[name="start_date"]').val('{{$param['start_date']}}');
        $('input[name="end_date"]').val('{{$param['end_date']}}');
        @else
        $('#reportrange span').html(moment().subtract(29, 'days').format('YYYY-MM-DD') + ' 至 ' + moment().format('YYYY-MM-DD'));
        $('input[name="start_date"]').val(moment().subtract(29, 'days').format('YYYY-MM-DD'));
        $('input[name="end_date"]').val(moment().format('YYYY-MM-DD'));
        @endif
        
                $('#reportrange').daterangepicker({
                    format: 'YYYY-MM-DD',
                    startDate: moment().subtract(29, 'days'),
                    endDate: moment(),
                    minDate: '01-01-2018',
                    maxDate: '12-31-2099',
                    dateLimit: {
                        days: 60
                    },
                    showDropdowns: true,
                    showWeekNumbers: true,
                    timePicker: false,
                    timePickerIncrement: 1,
                    timePicker12Hour: true,
                    ranges: {
                        '今天': [moment(), moment()],
                        '昨天': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
                        '最近七天': [moment().subtract(6, 'days'), moment()],
                        '最近30天': [moment().subtract(29, 'days'), moment()],
                        '本月': [moment().startOf('month'), moment().endOf('month')],
                        '上月': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
                    },
                    opens: 'left',
                    drops: 'down',
                    buttonClasses: ['btn', 'btn-sm'],
                    applyClass: 'btn-default',
                    cancelClass: 'btn-white',
                    separator: ' to ',
                    locale: {
                        applyLabel: '确定',
                        cancelLabel: '取消',
                        fromLabel: 'From',
                        toLabel: 'To',
                        customRangeLabel: '自定义',
                        daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
                        monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
                        firstDay: 1
                    }
                }, function (start, end, label) {
                    console.log(start.toISOString(), end.toISOString(), label);
                    $('#reportrange span').html(start.format('YYYY-MM-DD') + ' 至 ' + end.format('YYYY-MM-DD'));
                    $('input[name="start_date"]').val(start.format('YYYY-MM-DD'));
                    $('input[name="end_date"]').val(end.format('YYYY-MM-DD'));
        });
        
        

        

       
    </script>
@endsection

